package com.order.common;

import lombok.Data;

/**
 * @className: CommonResult
 * @Description: 通用返回结构
 * @author: JiaZhenpeng
 * @data: 2022/11/2017:32
 */
@Data
public class CommonResult {
    private Boolean result;
    private Integer status;
    private String msg;
    private Object data;

    public static CommonResult success(Object data){
        CommonResult result = new CommonResult();
        result.result = true;
        result.status = 200;
        result.msg = "操作成功";
        result.data = data;
        return result;
    }

    public static CommonResult success(String msg,Object data){
        CommonResult result = new CommonResult();
        result.result = true;
        result.status = 200;
        result.msg = msg;
        result.data = data;
        return result;
    }

    public static CommonResult fail(String msg){
        CommonResult result = new CommonResult();
        result.result = false;
        result.status = 429;
        result.msg = msg;
        result.data = null;
        return result;
    }

    public static CommonResult fail(Integer status, String msg){
        CommonResult result = new CommonResult();
        result.result = false;
        result.status = status;
        result.msg = msg;
        result.data = null;
        return result;
    }

}
